/**
 * 
 */
package com.yidu.drug.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.drug.common.Page;
import com.yidu.drug.model.FdPoBreakdownModel;
import com.yidu.drug.model.FdSellDetailModel;
import com.yidu.drug.service.FdSellDetailService;

/**
 * @author meilina
 * 2018年8月18日上午8:55:43
 * @version 1.0
 */
@Controller
@RequestMapping("/fdSellDetail")
public class FdSellDetailAction {
	@Resource
	private FdSellDetailService fdSellDetailService;
	/**
	 * 根据销售详情id查询总价格
	 * @param mxId
	 * @return
	 */
	@RequestMapping("/findAllPrice")
	@ResponseBody
	public Integer findAllPrice(String mxId){
		System.out.println("进入findAllPrice方法=================");
		
		Integer rows=fdSellDetailService.findAllPrice(mxId);
		return rows;
		
	}
	
	@RequestMapping("/findBySellIds")
	@ResponseBody
	public Map<String, Object> findBySellIds(HttpSession session,String sellId,int page,int limit){
		System.out.println(sellId+"=====================================================");
		FdSellDetailModel fdSellDetailModel=new FdSellDetailModel();
		fdSellDetailModel.setSellId(sellId);
		Page pages = new Page();
		pages.setPage(page);
		pages.setRows(limit);
		List<FdSellDetailModel> list=fdSellDetailService.findBySellIds(fdSellDetailModel, page, limit);
		Map<String, Object> map=new HashMap<String , Object>();
		map.put("code",0);
		map.put("msg","");
		map.put("count",fdSellDetailService.findRows(sellId));
		map.put("data", list);
		return map;
	}
	/**
	 * 分页查询
	 * @param session
	 * @param fdPoBreakdownModel
	 * @return
	 */
	@RequestMapping("/findRow")
	@ResponseBody
	public Page findRow(HttpSession session,FdSellDetailModel fdSellDetailModel){
		int total=fdSellDetailService.findCount(fdSellDetailModel);
		System.out.println("总行数"+total+"---------------------");
		Page page = new Page();
		int pages = 0;
		if(total % 10 == 0){
			pages = total / 10;
		}else {
			pages = total / 10 + 1;
		}
		page.setPage(pages);
		page.setTotalRows(total);
		page.setRows(10);
		return page;
	}
}
